<template>
  <div class="home">
    <p>随机一言：{{ p }}</p>
    <el-divider>爱是一道光，绿到他发慌 嘿嘿</el-divider>

    <p>舔狗日记:{{ t }}</p>
    <br />
    <el-button type="primary" @click="add">点击把随机一言存vuex</el-button>
  </div>
</template>

<script>
import { rj, dog } from "@/api/index";

export default {
  data() {
    return {
      p: "",
      t: "",
    };
  },
  mounted() {
    this.getrj();
    this.getdog();
  },
  methods: {
    async getrj() {
      let res = await rj();
      console.log(res);
      this.p = res.data.yiyan;
    },
    async getdog() {
      let res = await dog();
      console.log(res);
      this.t = res;
    },

    add() {
      this.$store.state.yiyan = this.p;
    },
  },
};
</script>
